<html>
<head>
<title>NOAA Autonomous Hydrophone Data Format</title>
</head>
<body text="#000000" bgcolor="#FFFFF0" link="#0000FF"
     vlink="#8A2BE2" alink="#008B8B">
<h3>
<a href="http://www.noaa.gov" TARGET="_parent">
<img SRC="http://www.pmel.noaa.gov/images/noaa-trans.gif"
     ALT="NOAA Logo" height=67 width=67 align=CENTER></a>
<a href="http://www.noaa.gov" TARGET="_parent">NOAA</a>/
<a href="http://www.pmel.noaa.gov/vents/home.html" TARGET="_parent">OERD</a>
Autonomous Hydrophone Data File Description
</h3>
<B>Last Update: November  27, 2001</B>
<P>
<B>Data Format Type 2 for the NOAA Autonomous Hydrophone Data Files
   from 1996 to 2000</B>
<P>
Each data file is 2097152 bytes long in binary format.
Block Size can be either 2048, 1025 or 512.  For this documentation
Block Size = 2048 bytes is used, and this makes 1024 blocks per file.
<P>
The 1st and Last 46 bytes of the data file contain the Start and
End dates respectively.  For example,
<PRE>
First 46 bytes = 'H0916N049W99 257:22:30:56:890257:22:32:47:900 ' = Start
Last  46 bytes = 'H0916N049W99 258:03:46:28:020258:03:48:19:150 ' = End
                               ^ Q-Tech Clock ^| On-Set Clock |     Time
</PRE>
where H03 is the Hrydophone ID,
08N and 110W is deployed Latitude and Longitude ( Approximation Only )
The 99 is year = 1999 and for Year 2000 on, the year will be 00, 01, etc.
Q-Tech Clock is very precise and independent.
On-Set Clock reads from the microprocessor's chip.
Both are synchronized with GPS time on deployment.
Both clocks contain Julian Date:Hour:Minute:Second:sss using the
Q-Tech Start Time as the example, Julian Date = 257,
Hour = 22, Minute = 30 and Second:sss = 56:890 = 56.890
<P>
<B>Q-Tech Clock is the one should be used.</B>
<P>
The Bytes between the 1st and last 46 bytes are Data.  Each byte is
one value between -128 to 127.  Note that the byte values: B may have
to be read in as unsigned 8-bit numbers.  Then convert them into signed
integers: I = B - 127.
<P>
Sample Rate is 100 points/second or Hz in general.  But because of the
hardware setup, Sample Rate must be deteremined for each data file by
the total data points: 2097060 = ( 2097152 - 46 - 46 ) divided by the
total time segments ( End Time - Start Time ).  Using the example above,
Sample Rate = (2097060/20131.13) = 104.17001.
where 20131.13 =  End Time - Start Time in seconds.
<P>
<B>Instructions for Decoding Autonomous Hydrophone Data Files</B>
<P>
The following instructions are one of many ways to decode the data file.
The objective is to give users examples for reading the data.
<P>
<B>Decoding Autonomous Hydrophone Data (Format 2) Block using
<A HREF="http://www.rsinc.com/idl/" onMouseOut="window.status=''; return true;"
onMouseover="window.status='Interactive Data Language from Research Systems, Inc.'; return true;">
IDL</A> Software Package</B>
<P>
The following IDL commands will decode an autonomous data file 1 block
at a time.  Note that this section is assuming readers know IDL
and how to refer to the IDL manual for detail.
<P>
Enter IDL ( in UNIX system, type IDL then IDL> should show up )
<PRE>
IDL> OPENR, 10, 'datafile.000'  ; datafile.000 is the data file name.
IDL> BLK  = ASSOC( 10, BYTARR( 2048 ) )  ; 2048 is the block size in bytes.
     where BLK will allow users to get 2048 bytes of data per read.

IDL> B    = BLK[0]  ; Read in the 1st block & store in the variable: B

     For the 1st block, the 1st 46 bytes is the Start Time, and
     only 2002 data points from bytes 46 to 2047, 1st byte position is 0.
IDL> PRINT, STRING( B[0:45] )   ; Show the Start Time.  For example,
     H0916N049W99 257:22:30:56:890257:22:32:47:900 
IDL> DATA = B[46:2047] - 127  ; All 2002 points data from the 1st block.
IDL> .... ; process DATA from 1st block.

IDL> B    = BLK[1]  ; Read in the 2nd block & store in the variable: B
IDL> DATA = B          - 127  ; All 2048 points data from the 2nd block.
IDL> .... ; process DATA from 2nd block.

     :::: etc ::::  Note that block can be read in any order.

IDL> B    = BLK[1023]  ; Read in the last block & store in the variable: B

     For the last block, the last 46 bytes is the End Time, and
     only 2000 data points from bytes 0 to 1999, 1st byte position is 0.
IDL> PRINT, STRING( B[2002:2047] )   ; Show the End Time.  For example,
     H0916N049W99 258:03:46:28:020258:03:48:19:150 
IDL> DATA = B[0:2001]  - 127  ; All 2002 points data from the last block.
IDL> .... ; process the last DATA

IDL> CLOSE, 10  ; Done with datafile.000
IDL> EXIT       ; Out of IDL.
</PRE>
<P>
<B>Decoding Autonomous Data Block using
<A HREF="http://www.mathworks.com/" onMouseOut="window.status=''; return true;"
onMouseover="window.status='Interactive Language from the MathWorks Company.'; return true;">
MatLab</A> Software Package</B>
<P>
The following MatLab commands will decode an autonomous data file 1 block
at a time.  Note that this section is assuming readers know MatLab
and how to refer to the MatLab manual for detail.
<P>
Enter MatLab ( in UNIX system, type MatLab then the MatLab working
window will show show up )
<PRE>
>>> FID = fopen( 'datafile.000', 'r' );
    where datafile.000 is the name of an autonomous data file,
     and 'r' indicates read only.

>>> s = fread( FID, 46 );  # Read the 1st 46 bytes, the start time.
>>> disp( char( s' ) )     # Convert the start time into characters & show it.
    H0916N049W99 257:22:30:56:890257:22:32:47:900 

    Move to the starting position of the end time (R).
>>> status = fseek( FID, 2097152 - 46, 'bof' );  # 2097152 is the file size.
>>> s = fread( FID, 46 );  # Read the next 46 bytes, the end time.
>>> disp( char( s' ) )     # Show the end time.  For example,
    H0916N049W99 258:03:46:28:020258:03:48:19:150 

    To decode the data points ( 1 block at a time in order),
>>> status = fseek( FID, 0, 'bof' );  # Move to the beginning of the file.
>>> n_points = 2048;                  # Block Size in bytes.
>>> data   = fread( FID, n_points );  # Read the 1st block: n_points of bytes.
>>> data   = data(47:2048) - 127;     # Skip the Start Time (1st 46 bytes)  & 
                                      # Make -128 <= data < 127.
    ::: Process the data from 1st block...

>>> data   = fread( FID, n_points );  # (1) Read the 2nd block.
>>> data   = data - 127;              # (2) Make -128 <= data < 127.

    ::: Process the data from 2nd block...

    ::: Repeat (1) & (2) for 3rd to 1023th blocks.

    For the last (1024th) block,
>>> data   = fread( FID, n_points );  # Read the last block.
>>> data   = data(1:2002) - 127;      # Skip the End Time and
                                      # Make -128 <= data < 127.

    To read any data block randomly, use the fseek() and fread() functions.
    For example,
>>> block_number  = 49;       # or any legal number between 0=1st block & 1023.
>>> file_position = n_points * block_number;      # n_points is the block size.
>>> status = fseek( FID, file_position, 'bof' );  # Move to the right position.
>>> data   = fread( FID, n_points ) - 127;   # Combine sets (1) & (2) into one.

>>> fclose( FID );  # Close the autonomous data file.
>>> exit;           # Out of MatLab.

</PRE>
<P>
<B>Other Data File Formats</B>
<P>
Data Format <A HREF="./HPdataFormat3.html"> Type 3</A>.  
Note that Data Format Type 1 was used for experiment and 
it is No longer being used.
<!-- P>
<B>T-Phase data files are available to be 
<A HREF="./TPDretrieval.html" onMouseOut="window.status=''; return true;"
 onMouseover="window.status='To T-Phase Data Retrieval Center.';return true;">
retrieved</A>.</B -->

</BODY>
</HTML>
